package uo.ri.bussiness.impl.admin;

import java.sql.SQLException;

import alb.util.jdbc.Jdbc;

public class UpdateMechanic extends MechanicBase {
	
	
	private Long id;
	private String nombre;
	private String apellidos;
	
	public UpdateMechanic(Long id, String nombre, String apellidos) {
		this.id = id;
		this.nombre = nombre;
		this.apellidos = apellidos;
	}
	
	public void execute(){
		
		try {
			
			prepareDB();
			
			mecanicosGateway.update(id, nombre, apellidos);
			connection.commit();
			
		} catch (SQLException e) {
			try {
				connection.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			throw new RuntimeException(e);
		}
		finally {
			Jdbc.close(connection);
		}
	}

}
